Skip to content

feat(nav3): [Part 3] Add the built-in SerialName mapper - #6703

Open
0xadam-brown wants to merge 1 commit into
feat/nav3-serial-name-stack-3from
feat/nav3-serial-name-mappers-7
Open

0xadam-brown wants to merge 1 commit into
feat/nav3-serial-name-stack-3from
feat/nav3-serial-name-mappers-7

Conversation

@0xadam-brown

@0xadam-brown 0xadam-brown commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

PR Stack (Nav3 SerialName Mapper)

This stack replaces the SerialName half of #6696. SerialNameAndProperties will follow in its own stack.


📜 Description

This PR adds the simpler of our two planned built-in mappers, BackStackEntryMapper.SerialName. Apps can pass it to SentryNavEffect instead of writing a mapper for every destination. It names each entry after its serial name: the key's @SerialName, or else its fully qualified class name. It records no properties.

Name resolution success...

For each entry type, the mapper checks that the class is @Serializable and not generic, looks up its serializer by reflection, and reads the descriptor's serial name. The result is cached per type, so the reflection runs once per type rather than on every navigation.

Lookups can fail for reasons that depend on the app: its types, its kotlinx.serialization version, and its R8 configuration. A failure only affects that type. Its entries are recorded as /unknown, other types are still named, and the mapper logs one warning for the type.

...and failure

PR records an unknown_entry_reason for every /unknown entry so developers can figure out what's going on without having to enable debug logging.

💡 Motivation and Context

Apps that use kotlinx.serialization have already given each key a name that doesn't depend on its obfuscated class name. Reusing it saves them from writing and maintaining a mapper for every key type.

addresses: JAVA-787 (link)

⚠️ Callouts

The built-in mappers are currently properties and not methods. That follows Kotlin's convention of using properties for stable, cached values and lets callers pass a mapper directly to SentryNavEffect without needing to remember an instance themselves.

A method-based constructor is the obvious alternative, whether simply returning the current cached maps or creating customized versions based on caller-provided configs. That approach seemed a bit less idiomatic to me (and for now overdone) given our current use-cases, so I decided against it. But we could always introduce it in the future without breaking the current API.

...that said, chime in if you disagree!

💚 How did you test it?

  • Unit tests, all of which are executed against our kotlinx-serialization-core floor (1.7.3) + the latest version (1.13.0).
  • R8 minifiction tests
  • Nav3 sample app manual tests

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

Continue with Part 4: Use the SerialName mapper in the Android samples.

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 1765464

@sentry

sentry Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.65.1 (1) release

⚙️ sentry-android Build Distribution Settings

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit 1765464.

Main concerns: public contract, dependencies customers inherit, reach.

Rules that block low also fired:

  • R1: code was truncated, omitted or a reduced context was used: sentry-android-navigation3/src/main/kotlin/io/sentry/compose/navigation3/internal/backstack/kotlinx/KotlinxBackStackEntryMapper.kt, sentry-android-navigation3/src/main/kotlin/io/sentry/compose/navigation3/internal/backstack/kotlinx/KotlinxCompatibilityProbe.kt, sentry-android-navigation3/src/main/kotlin/io/sentry/compose/navigation3/internal/backstack/kotlinx/KotlinxSerializerLookup.kt, sentry-android-navigation3/src/main/kotlin/io/sentry/compose/navigation3/internal/backstack/kotlinx/README.md, sentry-android-navigation3/src/main/kotlin/io/sentry/compose/navigation3/internal/contract/NavDataContract.kt and 16 more
  • R4: a public API record changed: sentry-android-navigation3/api/sentry-android-navigation3.api
  • R5: dependencies or bundled SDK versions changed: gradle/libs.versions.toml
  • R6: build or release configuration changed: gradle/dependency-matrix.versions.toml, gradle/libs.versions.toml, sentry-android-navigation3/build.gradle.kts, sentry-android-navigation3/proguard-rules.pro, settings.gradle.kts

This label is a hint for reviewers, not an approval.

@github-actions github-actions Bot removed the risk: medium PR risk score: medium label Nov 20, 2026
@0xadam-brown 0xadam-brown changed the title feat(nav3): [Nav3 Mappers 7] Add the SerialName mapper feat(nav3): [Part 7] Add the SerialName mapper Nov 20, 2026
Comment thread gradle/nav3.versions.toml Outdated
@@ -0,0 +1,15 @@
# Versions for sentry-android-navigation3's kotlinx.serialization compatibility checks, registered as

@0xadam-brown 0xadam-brown Nov 20, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Note that I've created a new dependency-matrix.versions.toml catalog alongside our libs.versions.toml. (An earlier version of this PR called it nav3.versions.toml.)

It holds two kotlinx.serialization versions:

  • kotlinxSerialization-floor (1.7.3): the oldest version we support, which the module compiles against. Nothing references it with version.ref, so Dependabot leaves it alone, and it only changes in a reviewed PR.
  • kotlinxSerialization-latestStable: the newest release, which Dependabot keeps current. Tests run against the floor by default, or against this with -Pnav3TestKotlinx=latestStable.

Keeping the floor in libs.versions.toml would mean shielding it with a Dependabot ignore rule. But ignore rules match a dependency's group and name, so they'd block the latestStable bumps too.

The R8 emulator check in #6783 (Part 5) watches both catalogs, so changing either version starts a run.

My clanker told me multiple version catalogs is a common convention, but chime in if you have concerns.

@0xadam-brown 0xadam-brown changed the title feat(nav3): [Part 7] Add the SerialName mapper feat(nav3): [Part 7] Add the built-in SerialName mapper Nov 20, 2026
@0xadam-brown
0xadam-brown marked this pull request as ready for review November 20, 2026 15:33
@0xadam-brown
0xadam-brown requested review from a team and adinauer as code owners November 20, 2026 15:33
@0xadam-brown
0xadam-brown requested review from markushi and runningcode and removed request for a team November 20, 2026 15:33

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@0xadam-brown 0xadam-brown added deep-dive PR needs a thorough review of design, behavior, and edge cases sanity-check PR needs a lightweight review for obvious issues and removed deep-dive PR needs a thorough review of design, behavior, and edge cases labels Nov 20, 2026
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-7 branch from 801de33 to 6937bd5 Compare November 25, 2026 15:30
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-6 branch from c5cc387 to 19c6402 Compare November 25, 2026 15:30
@0xadam-brown
0xadam-brown marked this pull request as draft November 25, 2026 15:33
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-7 branch from 6937bd5 to c8bea42 Compare November 27, 2026 15:16
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-6 branch from 19c6402 to 328049c Compare November 27, 2026 15:16
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 27, 2026
@0xadam-brown
0xadam-brown changed the base branch from feat/nav3-serial-name-mappers-6 to feat/nav3-serial-name-stack-3 November 27, 2026 15:26
@github-actions github-actions Bot removed the risk: medium PR risk score: medium label Nov 27, 2026
BackStackEntryMapper.SerialName names each back stack entry after its
kotlinx.serialization serial name, which R8 doesn't obfuscate, and
records no properties. kotlinx-serialization-core is a compileOnly
dependency at 1.7.3 or later. If the app's version can't be linked, the
mapper falls back to naming every entry /unknown.

The mapper returns null, which is public API, for entries it can't
name, so it reports why through an internal per-thread side channel
that the converter reads around each mapping call. Its reasons are
entry_not_annotated, generic_entry_type, serializer_not_found,
serializer_access_threw, and kotlinx_serialization_version.

Unit tests run against the 1.7.3 floor by default, and against the
latest stable release with -Pnav3TestKotlinx=latestStable.
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 27, 2026
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-stack-3 branch from fb33ea0 to 9909415 Compare November 27, 2026 15:27
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-7 branch from c8bea42 to 1765464 Compare November 27, 2026 15:27
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 27, 2026
@0xadam-brown 0xadam-brown changed the title feat(nav3): [Part 2] Add the built-in SerialName mapper feat(nav3): [Part 3] Add the built-in SerialName mapper Nov 27, 2026
@0xadam-brown
0xadam-brown marked this pull request as ready for review November 27, 2026 17:23
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 27, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium sanity-check PR needs a lightweight review for obvious issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants